<?php
require_once 'OAuthException.php';
require_once 'OAuthStoreMySql.php';

/**
 * This is class OAuthStore
 * Edit from original library OAuth-PHP of Marc Worrell <marcw@pobox.com>
 * 
 * @editor: Phong Linh <langxangvn@gmail.com>
 * @see http://code.google.com/p/oauth-php
*/
class OAuthStore {
	/**
	 * This is variable _instance description
	 */	
	static private $_instance = false;

	/**
	 * Request an instance of the OAuthStore
	 * 
	 * @param string $store The storage system
	 * @param array $options To pass to the storage system
	 * @param boolean $forceNewInstance If true, forces the instantiation of a new store.
	 * @throws OAuthException2
	 */
	public static function instance ($store = 'MySQL', $options = array(), $forceNewInstance = false ) {
		if (!self::$_instance or $forceNewInstance) {
			$class = 'OAuthStore' . $store;
				
			if (class_exists($class)) {
				self::$_instance = new $class($options);
			} else {
				throw new OAuthException('Could not find class ' . $class);
			}
		}
		
		return self::$_instance;       
	}
}
?>
